pub fn add_binary(a: String, b: String) -> String {
    let mut a1 = String::new();
    let mut b1 = String::new();
    if a.len() < b.len() {
        a1.push_str(&"0".repeat(b.len() - a.len()));
        a1.push_str(&a);
        b1 = b;
    } else if a.len() > b.len() {
        b1.push_str(&"0".repeat(a.len() - b.len()));
        b1.push_str(&b);
        a1 = a;
    } else {
        a1 = a;
        b1 = b;
    }
    let mut inc = 0u32;

    let rev1 = a1.chars().rev().map(|v| v.to_digit(10).unwrap()).collect::<Vec<u32>>();
    let rev2 = b1.chars().rev().map(|v| v.to_digit(10).unwrap()).collect::<Vec<u32>>();

    let mut tmp = String::new();
    for i in 0..a1.len() {
        let x = rev1.get(i).unwrap();
        let y = rev2.get(i).unwrap();
        match x + y + inc {
            3 => {
                tmp.push('1');
                inc = 1;
            },
            2 => {
                tmp.push('0');
                inc = 1;
            },
            1 => {
                tmp.push('1');
                inc = 0;
            },
            _ => {
                tmp.push('0');
                inc = 0;
            }
        }
    }
    if inc == 1 {
        tmp.push('1');
    }
    tmp.chars().rev().collect::<String>()
}

#[test]
fn test() {
    assert_eq!(add_binary(String::from("1010"), String::from("1011")), String::from("10101"));
}
